package com.stone.sys.service;

/**
 * <pre>
 * 用户信息操作Action
 * </pre>
 */

import java.util.HashMap;
import java.util.List;

import com.stone.business.equipment.pojo.TEquipmentBase;
import com.stone.business.equipment.pojo.TEquipmentParamByq;
import com.stone.business.equipment.pojo.TEquipmentParamByqBtqtjdq;
import com.stone.business.equipment.pojo.TEquipmentParamByqCyg;
import com.stone.business.equipment.pojo.TEquipmentParamByqFj;
import com.stone.business.equipment.pojo.TEquipmentParamByqLqq;
import com.stone.business.equipment.pojo.TEquipmentParamByqQyb;
import com.stone.business.equipment.pojo.TEquipmentParamByqTg;
import com.stone.business.equipment.pojo.TEquipmentParamByqTyzz;
import com.stone.business.equipment.pojo.TEquipmentParamByqYljdq;
import com.stone.business.equipment.pojo.TEquipmentParamByqYlsff;
import com.stone.business.equipment.pojo.TEquipmentParamByqYzjdq;
import com.stone.business.equipment.pojo.TEquipmentParamDlhgq;
import com.stone.business.equipment.pojo.TEquipmentParamDlhgqRz;
import com.stone.business.equipment.pojo.TEquipmentParamDlq;
import com.stone.business.equipment.pojo.TEquipmentParamDyhgq;
import com.stone.business.equipment.pojo.TEquipmentParamDyhgqRz;
import com.stone.business.equipment.pojo.TEquipmentParamGlkg;
import com.stone.business.equipment.pojo.TEquipmentParamKgg;
import com.stone.business.equipment.pojo.TEquipmentParamZhdq;
import com.stone.para.IConstant;
import com.stone.sys.pojo.TUser;
import com.stone.sys.pojo.TUserRole;
import com.stone.utils.seq.SeqUtil;

import frm.ssh.exception.AppException;
import frm.ssh.service.BaseService;

public class SysCommonService extends BaseService {
	
	/**
	 * 删除
	 * 
	 * @param ids
	 * @throws AppException
	 */
	public void doDelAll(String ids) {
		// 删除屏柜
		super.deleteAll(ids, "TBdzJg");
		// 删除屏柜下的设备
		super.deleteByDHql(" typeid in (" + ids + ")", null, "TEquipmentBase");

	}
	/**
	 * 删除屏柜下的设备
	 * @param ids
	 * @throws AppException
	 */
	public void deleteEquip(String ids) throws  AppException{
		
		
		// 查询出设备
		List<TEquipmentBase> rtn = super.findListByHql(" from TEquipmentBase where typeid in (" + ids + ")");
		
		// 根据设备类型删除子表信息(一次设备才有参数)
		for (TEquipmentBase e : rtn) {
			
			// 变压器
			if ("001".equals(e.getSblx())) {
				
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByq.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByqFj.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByqLqq.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByqCyg.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByqYlsff.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByqYzjdq.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByqBtqtjdq.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByqQyb.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByqYljdq.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByqTg.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamByqTyzz.class.getName());
				
				// 断路器
			} else if ("002".equals(e.getSblx())) {
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamDlq.class.getName());
				
				// 隔离开关
			} else if ("003".equals(e.getSblx())) {
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamGlkg.class.getName());
				
				// 组合电器
			} else if ("004".equals(e.getSblx())) {
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamZhdq.class.getName());
				
				// 开关柜
			} else if ("005".equals(e.getSblx())) {
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamKgg.class.getName());
				
				// 电流互感器
			} else if ("006".equals(e.getSblx())) {
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamDlhgq.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamDlhgqRz.class.getName());
				
				// 电压互感器
			} else if ("007".equals(e.getSblx())) {
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamDyhgq.class.getName());
				super.deleteByDHql("baseid in (" + e.getId() + ")", null, TEquipmentParamDyhgqRz.class.getName());
			}
			
		}
		// 删除屏柜下的设备
		super.deleteByDHql(" typeid in (" + ids + ")", null, "TEquipmentBase");
		// 删除屏柜
		super.deleteAll(ids, "TBdzJg");
		
	}
}
